import { View, Text, TouchableOpacity } from 'react-native';
import React from 'react';
import PropTypes from 'prop-types';
import { Modal } from '@ant-design/react-native';
import moment from 'moment';
import styles from './styles';
import { moveToRpBin } from '../../../../../comconfig/sqlfun';
import { debounce } from '../../../../../utils/common';

const Item = ({ navigation, objItem, getList }) => (
    <TouchableOpacity
        onPress={
            () => debounce(() => navigation.push(('报告详情'), { id: objItem.id }))
        }
        onLongPress={() => Modal.operation([
            {
                text: '删除',
                onPress: () => {
                    // delReport(parseInt(objItem.id, 10));
                    moveToRpBin(parseInt(objItem.id, 10), objItem.title);
                    getList();
                },
                style: { color: '#0F8DE9' },
            },
        ])}
    >
        <View style={styles.background}>
            <View style={styles.title}>
                <Text style={{ fontSize: 20, color: '#0079FF' }}>{objItem.title}</Text>
                <Text style={{ fontSize: 20 }}>的验收报告</Text>
            </View>
            <View style={styles.time}>
                <Text>{moment(objItem.time).format('YY-MM-DD')}</Text>
            </View>
        </View>
    </TouchableOpacity>
);

Item.defaultProps = {
    objItem: {},
    getList: () => {},
};
Item.propTypes = {
    objItem: PropTypes.objectOf(PropTypes.any),
    getList: PropTypes.func,
};
export default Item;
